package com.jiepu.daily.corejava.advanceed.part6thread.Yieid;

/**
 * @Description:
 * @author: xinjie.txt
 * @date: 2020/8/4  8:20
 */
public class YieldDemo1 {

	public static void main(String[] args) throws InterruptedException {
		Thread t1 = new Thread("A") {
			@Override
			public void run() {
				for (int i = 0; i <= 50; i++) {
					System.out.println(getName() + ":  " + i);
					if (i == 30) {
						Thread.yield();
					}
				} // for
			}
		};

		Thread t2 = new Thread("B") {
			@Override
			public void run() {
				for (int i = 0; i <= 50; i++) {
					System.out.println(getName() + ":   " + i);

				}

			}
		};


		t1.start();
		t2.start();

		t1.join();
		t2.join();
		System.out.println("main...");
	} //main
}
